package com.example.javaproject;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class Parent<K> {

    public Type getType() {
        Type genericSuperclass = getClass().getGenericSuperclass();
        if (!(genericSuperclass instanceof ParameterizedType)) {
            return Object.class;
        }
        Type type = ((ParameterizedType) genericSuperclass).getActualTypeArguments()[0];
        System.out.println(type.getTypeName());
        return type;
    }
}
